package com.fr.report.script.core.parser;

import com.fr.report.script.Calculator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class DatasetFunctionCall extends Atom
{
  private String sourceName;
  private String fnName;
  private ConditionalOrExpression[] arguments;

  DatasetFunctionCall(String paramString1, String paramString2, ConditionalOrExpression[] paramArrayOfConditionalOrExpression)
  {
    this.sourceName = paramString1;
    this.fnName = paramString2;
    this.arguments = paramArrayOfConditionalOrExpression;
  }

  public String getSourceName()
  {
    return this.sourceName;
  }

  public String getFnName()
  {
    return this.fnName;
  }

  public ConditionalOrExpression[] getArguments()
  {
    return this.arguments;
  }

  public Object eval(Calculator paramCalculator)
    throws UtilEvalError
  {
    return paramCalculator.resolveVariable(this);
  }

  public void traversal4Tiny(TinyHunter paramTinyHunter)
  {
    for (int i = 0; i < this.arguments.length; ++i)
      if (this.arguments[i] != null)
        this.arguments[i].traversal4Tiny(paramTinyHunter);
  }

  public String exString(Calculator paramCalculator)
  {
    StringBuffer localStringBuffer = new StringBuffer(this.sourceName);
    localStringBuffer.append(".");
    localStringBuffer.append(this.fnName);
    if (this.arguments != null)
    {
      localStringBuffer.append("(");
      for (int i = 0; i < this.arguments.length; ++i)
      {
        if (i > 0)
          localStringBuffer.append(", ");
        localStringBuffer.append(this.arguments[i].exString(paramCalculator));
      }
      localStringBuffer.append(")");
    }
    return localStringBuffer.toString();
  }

  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer(this.sourceName);
    localStringBuffer.append(".");
    localStringBuffer.append(this.fnName);
    if (this.arguments != null)
    {
      localStringBuffer.append("(");
      for (int i = 0; i < this.arguments.length; ++i)
      {
        if (i > 0)
          localStringBuffer.append(", ");
        localStringBuffer.append(this.arguments[i]);
      }
      localStringBuffer.append(")");
    }
    return localStringBuffer.toString();
  }

  public String getExpression(int paramInt1, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean)
  {
    StringBuffer localStringBuffer = new StringBuffer(this.sourceName);
    localStringBuffer.append(".");
    localStringBuffer.append(this.fnName);
    if (this.arguments != null)
    {
      localStringBuffer.append("(");
      for (int i = 0; i < this.arguments.length; ++i)
      {
        if (i > 0)
          localStringBuffer.append(", ");
        localStringBuffer.append(this.arguments[i].getExpression(paramInt1, paramInt2, paramInt3, paramInt4, paramBoolean));
      }
      localStringBuffer.append(")");
    }
    return localStringBuffer.toString();
  }

  public String[] parserParameter()
  {
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    int j = this.arguments.length;
    while (i < j)
    {
      localArrayList.addAll(Arrays.asList(this.arguments[i].parserParameter()));
      ++i;
    }
    return ((String[])localArrayList.toArray(new String[localArrayList.size()]));
  }
}